/** COPYRIGHT(C) 2008. Loc Phan. All Rights Reserved.
    A class that draws the chessboard
    @author Loc Phan
    @version 1.01 2008-11-11
*/

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JComponent;


public class CheckerBoard extends JComponent
{
   public void paint(Graphics g)
   {
      final int ROW = 8;
      final int COLUMN = 8;
      
      Graphics2D g1 = (Graphics2D)g;
      
      Color mycolor = null;
      Color black = Color.black;
      Color white = Color.white;
      
      for(int r=1;r<=ROW;r++)
      {
         for(int c=1;c<=COLUMN;c++)
         {
            if(c%2==0)
               mycolor = white;
            else mycolor = black;
            Square firstSquare = new Square(10*c*2,10*r*2,20,mycolor);
            firstSquare.draw(g1);
         }
         Color temp = white;
         white = black;
         black = temp;
      }
   }
}
